<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<include file="Public:base" />
<script type="text/javascript">
$(document).ready(function() {
	
	$("select[id='flag']").val('{$flag}');	
	$("[id^=lock]").on("click", function () {
		   var idval = $(this).attr("id");
		   var id = idval.split("_")[1];
	     	$.post("__URL__/lock/id/"+id, function (result) {
	     		if(result=="lock"){
	     			bootbox.alert("已锁定", function() {
	                  $("#lock_"+id).parent().html('状态： 锁定 | <a id="lock_'+id+'">开启</a>');
	              });
	     		}else if(result=="unlock"){
	     			bootbox.alert("已开启", function() {
		                  $("#lock_"+id).parent().html('状态： 开启 | <a id="lock_'+id+'">锁定</a>');
		              });
	     		}else {
	     			bootbox.alert("处理失败", function() {
	                  //console.log("Alert Callback");
	              });
	     		}
	     		
		    }); 
	});
	
	
	$("[id^=delhouse]").on("click", function () {
		var idval = $(this).attr("id");
		 bootbox.confirm("确认删除", function(result) {
         if(result){
      	   var id = idval.split("_")[1];
      	 	$.post("__URL__/del/id/"+id, function (result) {
	       		if(result=="del"){
                   $("#comm-item_"+id).hide();
	       		}else {
	       			bootbox.alert("删除失败", function() {
                       //console.log("Alert Callback");
                });
	       		}
	       		
		    }); 	
  	       	
         }
       });
   });
	
});
</script>
</head>
<body>
<include file="Public:header" />

<div class="home-index">

  <div class="col-xs-12">
    <div class="row">
      <h3>推送检索</h3>
      <div class="search-form">
	    <form class="form-inline" role="form" action="__URL__/index" method="get" >
	      <div class="form-group ">
	        <label class="sr-only" >关键词</label>
	        <input type="text" class="form-control" placeholder="按标题" name="title" value="{$title}">
	      </div>
	      <div class="form-group ">
		        <label class="sr-only" >推送位置</label>
		        <html:select id='flag' name='flag' style="form-control"  options='flaglist' first='推送位置' />
		      </div>
	      <button id="search" type="submit" class="btn btn-primary">检索</button>
	    </form>
	  </div>

	  <hr>
    	<div class="title">
    		<h3>推送列表</h3>
    		<a href="__MODULE__/PushData/add" class="btn btn-primary">添加</a>
    	</div>
		<volist name='data' id='vo'>
        <div id="comm-item_{$vo.id}" class="comm-item">
        	  
	          <div class="content">
	            <p class="art-title">标题：<a href="#">{$vo.title}</a></p>
	            <p>位置：{$vo.flag}</p>
	            <p>状态：
	            	<if condition=" $vo.status ">
			 		锁定 | <a id="lock_{$vo.id}" >开启</a>
			 		<else />
					 开启 | <a id="lock_{$vo.id}" >锁定</a>
					 </if>
	            </p>
	            <p>链接：
	            	<a href="{$vo.url}" target="_blank">点击查看</a>
	            </p>
	            <p>排序：{$vo.orderby}</p>
	            <p>发布时间：{$vo.created_at|date="Y-m-d H:i:s",###}</p>
	            <p class="slide-img">图片：<img src="__ROOT__{$vo.img}" ></p>
	          </div>
	
	          <div class="btn-group">
	            <a href="__URL__/modify/id/{$vo.id}"  class="glyphicon glyphicon-pencil" title="编辑"></a>
	            <a id="delhouse_{$vo.id}" href="javascript:;" class="glyphicon glyphicon-trash"></a>
	          </div>
	        </div>
	        </volist>
	        
	</div>
  </div>
  {$page}
</div>

</body>
</html>